package com.thirteen.peiban.once;

import com.alibaba.excel.EasyExcel;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author 十三
 * @create 2023-12-07 3:02
 * @Description:
 */
public class ImportCrawlingUser {

    public static void main(String[] args) {
        String fileName = "D:\\IDE\\IDEA\\workspace\\user-center-backend\\src\\main\\resources\\prodExcel.xlsx";
        // 这里 需要指定读用哪个class去读，然后读取第一个sheet 同步读取会自动finish
        List<CrawlingTableUserInfo> userInfoList =
                EasyExcel.read(fileName).head(CrawlingTableUserInfo.class).sheet().doReadSync();
        System.out.println("总数 = " + userInfoList.size());
        Map<String, List<CrawlingTableUserInfo>> listMap = userInfoList.stream()
                .filter(userInfo -> StringUtils.isNotEmpty(userInfo.getUsername()))
                .collect(Collectors.groupingBy(CrawlingTableUserInfo::getUsername));
        System.out.println("不重复的昵称数 = " + listMap.keySet().size());
    }

}
